<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/11/7
  Time: 13:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/mb/jsp/common.jsp" %>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>XX记录</title>
</head>
<body ontouchstart="">
<div class="detailTop pf w100 of">
    <div class="w100 of tc cf f18">
        <span class="pa" style="left: 2px;" onclick="javascript:history.back();"><img src="mb/images/top_back_white.png" style="margin-top: 4px;height: 40px;width: 40px;"/></span>
		记录
    </div>
</div>


<div id="container" class="container db jz" style="padding-bottom: 0;padding-top: 46px;">

    
    <div id="resText"></div><!--resText-->
        <div id="loading" class="w100">
            <img src="mb/images/loading.gif" alt="正在加载" class="db jz hauto" style="width: 15px;">
            <div class="w100 tc f10 c9">正在加载</div>
        </div>
         <div id="loadingComplete" class="w100" style="display:none;">
            <div class="w100 tc f12 c9">已加载完所有数据</div>
        </div>
    
</div>
 <script>
   //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
        
     var recordKind = getUrlParam('recordKind');
	  var m = "";
	  
	  var  backBtn = '<span class="pa" style="left: 2px;" onclick="javascript:history.back();"><img src="mb/images/top_back_white.png" style="margin-top: 4px;height: 40px;width: 40px;"/></span>';

		if(recordKind == "kangmaidou"){
		  m = 1671;
		  $(".detailTop div").html(backBtn+"抗霾豆记录");
		}
		else if(recordKind == "shengwangzhi"){
		  m = 1661;
		  $(".detailTop div").html(backBtn+"活跃记录");
		}
		if(recordKind == "caidan"){
		  m = 1780;
		  $(".detailTop div").html(backBtn+"财单记录");
		}
		if(recordKind == "zongedu"){
		  m = 1787;
		  $(".detailTop div").html(backBtn+"现货瓶数记录");
		}
		
 
 
 
 
	var curpage = 1;
	var total = "";
	var rmbtype = "";/* 0：余额变动记录  1：收益变动记录 */
	
   //加载新数据
    function getData() {
     console.log("recordKind: " +recordKind);
     console.log("m: " +m);
        $.ajax({
            url: "PlugServlet",
            data: JSON.stringify({m: m,curpage:curpage,rmbtype:rmbtype}),
            type: 'post',
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            beforeSend: function () {
                showProgressDg();
            },
            success: function (data) {
               if (data.state == 1) {
                
               total = data.total;
                  showData(data.list);
                } else {
                    // 其他错误弹出提示
                    showToast(data.info);
                }
            },
            error: function (data) {
                showToast(data.info);
            },
            complete: function () {
                closeProgressDg();
            }
        });
         return total;
         
    }

 function showData(list)
    {
    console.log(list);
    	var htmlStr="";
    	var htmlStr2="";
    	
    	$.each(list, function(index, obj) 
    	{
			  //抗霾+活跃
			var changeValue = obj.logvalue;
			var changeValueBlcok ="";
			
			if(changeValue == 0){
				changeValueBlcok = '<p class="c3 f15">'+changeValue+'<p>';
			}
			else if(changeValue > 0){
				changeValueBlcok = '<p class="orange2 f15">+'+changeValue+'<p>';
			}
			else if(changeValue < 0){
				changeValueBlcok = '<p class="cgreen f15">-'+changeValue+'<p>';
			}
    		htmlStr +=
	    		   		'<p class="w100 jz lh2 c6 tc f13">'+dataToString(obj.ctime, "yyyy-MM-dd HH:mm:ss")+'</p>'+
						'<section class="w100 bcf of">'+
								'<div class="w92 jz mgt10 mgb10 df">'+
									'<div class="circle of" style="height: 40px;width:40px;"> '+
										'<img src="mb/images/swjl.png" class="db w100 h100">'+	
									'</div>'+
									'<div class="c3 f16 mgl10"  style="flex-grow: 2;">'+obj.typeAbout+'</div>'+
									'<div>'+
										'<p class="c3 f15">'+changeValueBlcok+'<p>'+
										'<p class="c3 f14 mgt10">'+obj.newlogvalue+'<p>'+
									'</div>'+
								'</div>'+
							'</section>';
							
							
							
					    
					    
			 //财单记录
			var changeValue2 = obj.rmb;
			var changeValueBlcok2 ="";
			var imgStr2 ="";
			
			if(changeValue2 == 0){
				changeValueBlcok2 = '<p class="c3 f15">'+changeValue2+'<p>';
				imgStr2='<img src="mb/images/cdjl-orange.png" class="db w100 h100">';
			}
			else if(changeValue2 > 0){
				changeValueBlcok2 = '<p class="cred f15">'+changeValue2+'<p>';
				imgStr2='<img src="mb/images/cdjl-orange.png" class="db w100 h100">';
			}
			else if(changeValue2 < 0){
				changeValueBlcok2 = '<p class="cgreen f15">'+changeValue2+'<p>';
				imgStr2='<img src="mb/images/cdjl-red.png" class="db w100 h100">';
			}
					    
			htmlStr2 +=
					'<p class="w100 jz lh2 c6 tc f13">'+obj.timeAbout+'</p>'+
					'<section class="w100 bcf of">'+
							'<div class="w92 jz mgt10 mgb10 df">'+
								'<div class="circle of" style="height: 40px;width:40px;"> '+
									imgStr2+	
								'</div>'+
								'<div class="c3 f16 mgl10"  style="flex-grow: 2;">'+obj.typename+'</div>'+
								'<div>'+
									'<p class="c3 f15">'+changeValueBlcok2+'<p>'+
									'<p class="c3 f14 mgt10">'+obj.nowrmb+'<p>'+
								'</div>'+
							'</div>'+
						'</section>';
						
    	});
    	
    	 if(recordKind == "kangmaidou"||recordKind == "shengwangzhi"){
    	     $("#resText").after(htmlStr);
    	 }
    	  if(recordKind == "caidan"||recordKind == "zongedu"){
    	     $("#resText").after(htmlStr2);
    	 }
    	
    }
   
 
	$(document).ready(function(){
	
	getData();
	
			$(window).scroll(function () {
	        if ($(window).scrollTop() == $(document).height() - $(window).height()) {
		           if (curpage < total) {
		               curpage++;
		                $("#loading").slideDown();
		               getData();
		               $("#loading").slideUp();
	              }
	              else {
		               	$("#loadingComplete").slideDown();
		               	var close = function (){
		               	  $("#loadingComplete").slideUp()
		               	};
		   				setTimeout(close,3000);
		   				clearTimeout(close); 
		   				return false;
	              } 
	              
	        }
	 
	    });
	   
	});
</script>


</body>
</html>
